package cn.xorange.commons.file.service;

import cn.xorange.commons.file.configuration.MinioConfig;
import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

/**
 * Minio 文件存储
 * 
 * @author ruoyi
 */
@Service
@ConditionalOnProperty(name = "oss.minio.enable",havingValue = "true")
public class MinioUploadService
{
    @Autowired
    private MinioConfig minioConfig;

    @Autowired
    private MinioClient client;

    public String upload(String dir,MultipartFile file) {
        return null;
    }

    public boolean delFile(String path){
        return true;
    }

    ///**
    // * 本地文件上传接口
    // *
    // * @param file 上传的文件
    // * @return 访问地址
    // * @throws Exception
    // */
    //@Override
    //public String uploadFile(MultipartFile file) throws Exception
    //{
    //    String fileName = FileUtils.extractFilePathname(file);
    //    PutObjectArgs args = PutObjectArgs.builder()
    //            .bucket(minioConfig.getBucketName())
    //            .object(fileName)
    //            .stream(file.getInputStream(), file.getSize(), -1)
    //            .contentType(file.getContentType())
    //            .build();
    //    client.putObject(args);
    //    return StringUtils.format("{}/{}/{}",minioConfig.getDomain(),minioConfig.getBucketName(),fileName);
    //}
}
